Skip to content

chore: backfill email-domain member organization dates (CM-1107)#4064

Merged
skwowet merged 27 commits intomainfrom
script/CM-1107
May 3, 2026
Merged

chore: backfill email-domain member organization dates (CM-1107)#4064
skwowet merged 27 commits intomainfrom
script/CM-1107

Conversation

@skwowet
Copy link
Copy Markdown
Collaborator

@skwowet skwowet commented Apr 28, 2026

Summary

Adds a one-off backfill script for existing email-domain member organization rows with missing dates.

The script:

  • Finds active email-domain member organizations where dateStart and dateEnd are null.
  • Uses verified email identities and activityRelations.memberId/platform/username to find activity-date evidence.
  • Reuses the stint inference logic to apply date ranges.
  • Queues changed members in Redis for affiliation recalculation.

Note

Medium Risk
Writes backfilled dateStart/dateEnd values into memberOrganizations and changes the Redis set name used for affiliation recalculation, so a mistake could impact historical work-experience timelines or leave members un-recalculated.

Overview
Adds a one-off backfill script (backfill-email-domain-member-organization-dates) that finds email-domain memberOrganizations with missing dates, derives date evidence from verified emails + activityRelations, and applies inferred stint inserts/updates in a DB transaction (including enforcing affiliation-block policies).

Introduces new data-access queries to fetch affected member IDs and per-org activity dates, and standardizes the Redis queue key used to trigger member affiliation recalculation to recalculate-member-affiliations (updated in the script executor worker and used by the new script).

Reviewed by Cursor Bugbot for commit c9fac03. Bugbot is set up for automated code reviews on this repo. Configure here.

@skwowet skwowet self-assigned this Apr 28, 2026
Copilot AI review requested due to automatic review settings April 28, 2026 13:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a one-off backfill script to infer and persist missing dateStart/dateEnd for existing email-domain memberOrganizations, using activity evidence and existing stint-inference logic, and queues affected members for affiliation recalculation.

Changes:

  • Add DAL query helpers + types to find email-domain member orgs missing dates and derive per-org activity dates.
  • Add a backend script to run the backfill in batches and enqueue impacted members in Redis.
  • Rename the Redis set key used by the script executor worker workflow that recalculates member affiliations.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
services/libs/data-access-layer/src/members/types.ts Adds a typed result shape for email-domain org activity date rows.
services/libs/data-access-layer/src/members/organizations.ts Adds queries for (1) memberIds with undated email-domain orgs and (2) org activity dates for stint inference.
services/apps/script_executor_worker/src/activities/block-project-organization-affiliations.ts Renames the Redis set key used to queue/pop members for affiliation recalculation.
backend/src/bin/scripts/backfill-email-domain-member-organization-dates.ts New one-off backfill script: batch processing, stint inference, DB updates/inserts, Redis enqueue.
backend/package.json Adds an npm script entry to run the new backfill script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

skwowet and others added 6 commits April 28, 2026 19:11
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
…and reuse

Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
skwowet added 6 commits April 29, 2026 17:37
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
… in member organization job

Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 29, 2026 16:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

skwowet added 5 commits April 30, 2026 14:14
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0c51d12. Configure here.

Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 30, 2026 10:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/libs/data-access-layer/src/members/organizations.ts
Copilot AI review requested due to automatic review settings April 30, 2026 17:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

skwowet added 2 commits May 3, 2026 19:06
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Base automatically changed from improve/CM-1105 to main May 3, 2026 15:37
@skwowet skwowet merged commit fe77e8b into main May 3, 2026
15 checks passed
@skwowet skwowet deleted the script/CM-1107 branch May 3, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants